#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include<stdlib.h>
#include<string.h>
 
int main(int argc, char *argv[])
{

		int in=-1;
		int ret=-1;
		char buf[100];
		int n=*argv[1]-'0';
		in=open(argv[2],O_RDWR);
		if(in==-1){

				printf("Open error!\n");
				return -1;
		}
		
		ret=read(in,buf,100);
                

		if(ret<0){
				printf("Read error!\n");
				return -1;
		}
		
		
                mytail(buf,n);
                      
               

		close(in);
		

                
		return 0;
}

void mytail(char STR[100],int n)
{
               int i,count=0;
               for(i=0;STR[i]!='/0';i++)
    {         if(STR[i]=='\n')
                count++;
           
               if(count<n-1) 
                  continue;
                else {printf("%c",STR[i]);
                  if(STR[i]=='\n')
                   printf("\n");
                   
               }
             
     }
}
